package com.zidian.leader.common.view;

import com.github.mikephil.charting.components.AxisBase;
import com.github.mikephil.charting.formatter.IAxisValueFormatter;

import java.util.List;

/**
 * Created by GongCheng on 2016/11/9.
 */

public class MyXAxisValueFormatter implements IAxisValueFormatter {
    private List<String> values;

    public MyXAxisValueFormatter(List<String> values) {
        this.values = values;
    }

    @Override
    public String getFormattedValue(float value, AxisBase axis) {

        int position = (int) value;
        //防止越界
        if (value - 1 >= values.size()) {
            return "test";
        }
        return values.get(position - 1);
    }

    @Override
    public int getDecimalDigits() {
        return 0;
    }
}
